<?php
/**
 * Created by PhpStorm.
 * User: 仙女大人
 * Date: 2019/6/12
 * Time: 15:58
 */

namespace app\admin\controller;
use think\Controller;
use think\Request;
use org\Auth;
use think\Session;

class Base extends Controller
{
    protected $cur_action;
    public function _initialize()
    {
        parent::_initialize();      // 继承父类中的内容方法
        $user = Session::get('user');

        // 判断超级管理员
        if(in_array($user['id'],config('administrator'))) {
            return true;
        }

        $auth = new Auth();
        $this->cur_action = request()->module().'/'.request()->controller().'/'.lcfirst(request()->action());
        if($user == null) {
            $this->error('请您登陆后使用');
        }

        if(!$auth->check($this->cur_action,$user['id'])){
            $this->error('抱歉，您没有权限使用！');
        }

    }
}